/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.raitcon.hibernate.backbean;

import com.raitcon.hibernate.bean.Grado;
import com.raitcon.hibernate.db.GradoDB;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;
import org.apache.log4j.Logger;

/**
 *
 * @author Mike
 */
@ManagedBean(name="gradoBean")
@RequestScoped
public class GradoBean implements Serializable {
    
   protected static Logger log = Logger.getLogger(GradoBean.class); 
   private static  final  long serialVersionUID=-2377612760546575078L;
   private String currentItem = "";
   private List<SelectItem> gradoList = new ArrayList<SelectItem>();
   private String selectedGrado = "0";
   
   @PostConstruct
   protected void init(){
       log.debug("init...gradoBean");
       GradoDB gradoDB=new GradoDB();
        List<Grado> gradoLst=gradoDB.getGradoAll();
        SelectItem item = new SelectItem("0", "--Selecciona Grado--");
         getGradoList().add(item);
        for(Grado g:gradoLst){
            item = new SelectItem(g.getIdGrado(), g.getDescripcion());
            getGradoList().add(item);
        }
      
   }

    /**
     * @return the selectedGrado
     */
    public String getSelectedGrado() {
        return selectedGrado;
    }

    /**
     * @param selectedGrado the selectedGrado to set
     */
    public void setSelectedGrado(String selectedGrado) {
        this.selectedGrado = selectedGrado;
    }

    /**
     * @return the gradoList
     */
    public List<SelectItem> getGradoList() {
        return gradoList;
    }

    /**
     * @param gradoList the gradoList to set
     */
    public void setGradoList(List<SelectItem> gradoList) {
        this.gradoList = gradoList;
    }

    /**
     * @return the currentItem
     */
    public String getCurrentItem() {
        return currentItem;
    }

    /**
     * @param currentItem the currentItem to set
     */
    public void setCurrentItem(String currentItem) {
        this.currentItem = currentItem;
    }
    
}
